<template>
	<section>		
		<el-col :span="24" v-if="$route.query.stage==1||$route.query.stage==2">
			<el-breadcrumb separator=">">
			  <el-breadcrumb-item :to="{ path: '/coursetask?id='+$route.query.id }">作业批改</el-breadcrumb-item>		  
			  <el-breadcrumb-item  :to="{ path: '/coursetaskstage?'+'id='+$route.query.id+'&unitId='+$route.query.unitId+'&stage='+$route.query.stage}">{{UnitInfo.stageUnit.name}}</el-breadcrumb-item>
			  <el-breadcrumb-item>{{UnitInfo.user.realName}}</el-breadcrumb-item>
			</el-breadcrumb>			
		</el-col>
		<el-col :span="24" v-if="$route.query.stage==3||$route.query.stage==4">
			<el-breadcrumb separator=">">
			  <el-breadcrumb-item :to="{ path: '/coursetask?id='+$route.query.id }">作业批改</el-breadcrumb-item>		  
			  <el-breadcrumb-item  :to="{ path: '/coursetaskstage?'+'id='+$route.query.id+'&stage='+$route.query.stage}" v-show="$route.query.stage==3">沙盘推演</el-breadcrumb-item>
			  <el-breadcrumb-item  :to="{ path: '/coursetaskstage?'+'id='+$route.query.id+'&stage='+$route.query.stage}" v-show="$route.query.stage==4">项目路演</el-breadcrumb-item>
			  <el-breadcrumb-item>{{UnitInfo.name}}</el-breadcrumb-item>
			</el-breadcrumb>			
		</el-col>		
		<div v-if="$route.query.stage==1||$route.query.stage==2">				
			<el-col :span="24" >
				<el :span="24" >
					<h1>作业情况：</h1>
					<p>所属学生：{{UnitInfo.user.realName}}</p>
					<p>提交时间：{{UnitInfo.commitTime}}</p>
					<p>状态：{{UnitInfo.isCommitted?'已提交':'未提交'}}/{{UnitInfo.isPublished?'已评分':'未评分'}}</p>
				</el>
				<el-row :gutter="20" style="margin: 30px 0;">
					<h1 >作业内容</h1>
					<el-col  :span="20" v-for="el in UnitInfo.stageUnit.vproblems" style="margin-bottom: 10px;">
						<div v-if="el.type==1">
							<el-form ref="el" :model="el" label-width="80px">
								<el-form-item  label="问题:">
									{{el.question}} <span style="color: red;">(总分{{el.score}}分)</span>
								</el-form-item>
							</el-form>
							<el-form ref="el" :model="el" label-width="80px">
								<el-form-item  label="回答:">
									<el-input v-model="el.answer" disabled="disable"  type="textarea"></el-input>
								</el-form-item>
							</el-form>	
							<el-form >
								<el-form-item  label="本题得分：" label-width="110px">
									<el-input v-model="el.problemScore" v-on:change="ChangeaddScore(el.problemScore,el.score)" :disabled="UnitInfo.isPublished" placeholder="请输入分数" type="number" style="width: 30%;"></el-input>
								</el-form-item>		
								<el-form-item  label="评语：" label-width="110px">
									<el-input v-model="el.remark" :disabled="UnitInfo.isPublished"  type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入评论内容"  style="width:80%;"></el-input>
								</el-form-item>										
							</el-form>
						</div>
						<div v-if="el.type==2">
							<el-form ref="el" :model="el" label-width="80px">
								<el-form-item  label="问题:">
									{{el.question}} <span style="color: red;">(总分{{el.score}}分)</span>
								</el-form-item>
								<el-form-item ref="el" label="回答:" :model="el" >
								    <el-radio-group v-model="el.answer" disabled="disable" >
								      <el-radio label="A">{{el.optionA}}</el-radio></br></br></br>
								      <el-radio label="B">{{el.optionB}}</el-radio></br></br></br>
								      <el-radio label="C">{{el.optionC}}</el-radio></br></br></br>
								      <el-radio label="D">{{el.optionD}}</el-radio></br></br>
								      <el-radio v-if="el.optionE" label="E">{{el.optionE}}</el-radio></br></br>
								      <el-radio v-if="el.optionF" label="F">{{el.optionF}}</el-radio>
								    </el-radio-group>
								</el-form-item>	
								<el-form-item   label="本题得分：" label-width="120px" style="color: red;">
									{{el.problemScore?el.problemScore:0}}分
								</el-form-item>									
							</el-form>
						</div>		
						<div v-if="el.type==3">
							<el-form ref="el" :model="el" label-width="80px">
								<el-form-item  label="问题:">
									{{el.question}} <span style="color: red;">(总分{{el.score}}分)</span>
								</el-form-item>
								<el-form-item ref="el" label="回答:" :model="el" >
								    <el-checkbox-group v-model="el.answer" >
								      <el-checkbox label="A" disabled="disable">{{el.optionA}}</el-checkbox></br>
								      <el-checkbox label="B" disabled="disable">{{el.optionB}}</el-checkbox></br>
								      <el-checkbox label="C" disabled="disable">{{el.optionC}}</el-checkbox></br>
								      <el-checkbox label="D" disabled="disable">{{el.optionD}}</el-checkbox></br>
								      <el-checkbox v-if="el.optionE" label="E" disabled="disable">{{el.optionE}}</el-checkbox></br>
								      <el-checkbox v-if="el.optionF" label="F" disabled="disable">{{el.optionF}}</el-checkbox>
								    </el-checkbox-group>
								</el-form-item>	
								<el-form-item  label="本题得分：" label-width="120px" style="color: red;">
									{{el.problemScore?el.problemScore:0}}分
								</el-form-item>									
							</el-form>
						</div>		
						<div v-if="el.type==4">
							<el-form ref="el" :model="el" label-width="80px">
								<el-form-item  label="问题:">
									{{el.question}} <span style="color: red;">(总分{{el.score}}分)</span>
								</el-form-item>
								<el-form-item ref="el" label="回答:" :model="el" >
						    	    <el-radio-group v-model="el.answer" size="medium" disabled="disable" >
								      <el-radio label="1" value="">正确</el-radio>
								      <el-radio label="0" value="">错误</el-radio>
								    </el-radio-group>
								</el-form-item>		
								<el-form-item   label="本题得分：" label-width="120px" style="color: red;">
									{{el.problemScore?el.problemScore:0}}分
								</el-form-item>									
							</el-form>
						</div>						
					</el-col>			
				</el-row>
				<el-row>
					<h1 >作业得分</h1>		
					<el-form  label-width="80px">
						<el-form-item>
							<el-input v-model="addScore" disabled="disable" style="width: 30%;"></el-input>
						</el-form-item>
					</el-form>						
				</el-row>
			</el-col>
		</div>
		<div v-show="$route.query.stage==3">
			
			<el-col :span="20" :offset="2">
				<h1 style="text-align: center;margin: 20px 0;font-size:18px;">{{UnitInfo.name}}</h1>
				
				<div :span="24" >
					<h1>项目基本信息</h1>
			        <div class="edit_container">
			          <quill-editor v-model="UnitInfo.inferIntro"
			                        ref="myQuillEditor"
			                        class="editer"
			                        :disabled="role!='student'" 
			                       >
			          </quill-editor>
			        </div>				
				</div>	
				<el-row :gutter="20" style="margin: 30px 0;">
					<h1 >图纸</h1>
					<el-col  :span="6" v-for="el in UnitInfo.teamDrawingCommits" style="margin-bottom: 10px;">
						<div class="coursetags" v-on:click="showdrawDislog(el)">
							<el-tag type="success" v-if="el.drawingTypeId==1">消费者体验流程图</el-tag>	
							<el-tag type="success"  v-if="el.drawingTypeId==2">典型人物</el-tag>
							<el-tag type="success"  v-if="el.drawingTypeId==3">服务蓝图</el-tag>
							<el-tag type="success"  v-if="el.drawingTypeId==4">商业模式画布</el-tag>
							<el-tag type="success"  v-if="el.drawingTypeId==5">电梯演讲</el-tag>
							<el-tag type="success"  v-if="el.drawingTypeId==6">洞察分析</el-tag>
							<el-tag type="success"  v-if="el.drawingTypeId==7">思维导图</el-tag>						
						</div>
					</el-col>		
				</el-row>			
				<el-row :gutter="20" style="margin: 30px 0;">
					<h1>沙盘推演及教师点评视频</h1>
					<el-col style="margin-bottom: 10px;" :span="8">
					    <el-card  :body-style="{ padding: '0px' }" class="video-box" >
					      <p class="iconfont icon-luyanzhongxin"  v-on:click="lookvideo(UnitInfo.inferVideoPath)" ></p>
					      <div class="video-imgbox">
					      </div>
					    </el-card>
					</el-col>		
				</el-row>	
				<el-row>
					<el-form >
						<el-form-item  label="作业得分：" label-width="110px">
							<el-input v-model="UnitInfo.inferScore" :disabled="UnitInfo.isInferPublished" placeholder="请输入分数" type="number" style="width: 30%;"></el-input>
						</el-form-item>		
						<el-form-item  label="评语：" label-width="110px">
					        <div class="edit_container">
					          <quill-editor v-model="UnitInfo.inferRemark" 
					                        ref="myQuillEditor"
					                        class="editer"
					                        :disabled="UnitInfo.isInferPublished" 
					                        placeholder="请输入评论内容" 
					                       >
					          </quill-editor>
					        </div>									
						</el-form-item>										
					</el-form>						
				</el-row>
			
			</el-col>		
		</div>
		<div v-if="$route.query.stage==4">		
			<el-col :span="20" :offset="2">
				<h1 style="text-align: center;margin: 20px 0;font-size:18px;">{{UnitInfo.name}}</h1>		
				<div :span="24" >
					<h1>项目基本信息</h1>
			        <div class="edit_container">
			          <quill-editor v-model="UnitInfo.roadIntro"
			                        ref="myQuillEditor"
			                        class="editer"
			                        disabled="disabled" 
			                       >
			          </quill-editor>
			        </div>				
				</div>	
				<el-row :gutter="20" style="margin: 30px 0;">
					<h1>路演PDF文件</h1>
					<el-col style="margin-bottom: 10px;" :span="24">
						<iframe :src="UnitInfo.roadPdfPath" width="100%" height="600px">
						 This browser does not support PDFs. Please download the PDF to view it: <a href="/test.pdf" rel="external nofollow" >Download PDF</a>
						</iframe>
					</el-col>		
				</el-row>				
				<el-row :gutter="20" style="margin: 30px 0;">
					<h1>路演推演及教师点评视频</h1>
					<el-col style="margin-bottom: 10px;" :span="8">
					    <el-card  :body-style="{ padding: '0px' }" class="video-box" >
					      <p class="iconfont icon-luyanzhongxin"  v-on:click="lookvideo(UnitInfo.roadVideoPath)" ></p>
					      <div class="video-imgbox">
					      </div>
					    </el-card>
					</el-col>		
				</el-row>	
				<el-row>
					<el-form >
						<el-form-item  label="作业得分：" label-width="110px">
							<el-input v-model="UnitInfo.roadScore" :disabled="UnitInfo.isRoadPublished" placeholder="请输入分数" type="number" style="width: 30%;"></el-input>
						</el-form-item>		
						<el-form-item  label="评语：" label-width="110px">
					        <div class="edit_container">
					          <quill-editor v-model="UnitInfo.roadRemark" 
					                        ref="myQuillEditor"
					                        class="editer"
					                        :disabled="UnitInfo.isRoadPublished" 
					                        placeholder="请输入评论内容" 
					                       >
					          </quill-editor>
					        </div>									
						</el-form-item>										
					</el-form>						
				</el-row>				
			</el-col>		
		</div>		
		<el-dialog  title="查看视频" :fullscreen="false" custom-class="videodialog"  v-model="lookVisible" :close-on-click-modal="false">	
			<template>
				<video width="100%"  v-bind:src="path" height="" controls>
				</video>
			</template>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="lookVisible = false">关闭</el-button>
			</div>
		</el-dialog>	
		<el-dialog  title="图纸" v-dialogDrag custom-class="drawdislog" v-model="addFormVisible">
			<template >
				<dians v-if="drawingTypeId==2" :tochild="Drawdian" ref="dianss"></dians>
				<fenxi v-if="drawingTypeId==6" :tochild="Drawfenxi" ref="dianss"></fenxi>
				<lantu  v-if="drawingTypeId==3":tochild="Drawlantu" ref="dianss"></lantu>
				<shangye v-if="drawingTypeId==4" :tochild="Drawshangye" ref="dianss"></shangye>
				<yanjiang v-if="drawingTypeId==5" :tochild="Drawyanjiang" ref="dianss"></yanjiang>
				<tiyan v-if="drawingTypeId==1" :tochild="Drawtiyan" ref="dianss"></tiyan>
				<iframe v-show="drawingTypeId==7" src="http://www.zcxy360.com/sandtable/naotu/index.html" width="100%" height="1200px" id="naotu"></iframe>						
			</template>						
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="addFormVisible = false">关闭</el-button>
			</div>				
		</el-dialog>	
		<el-col :span="24" style="text-align: center;"  v-if="$route.query.stage==1">
			<el-button type="danger" @click.native="retrunbaseWork" v-if="!UnitInfo.isPublished">作业打回</el-button>
			<el-button type="warning" @click.native="Submitwork" v-if="!UnitInfo.isPublished">提交并发布分数</el-button>
		</el-col>
		<el-col :span="24" style="text-align: center;"  v-if="$route.query.stage==2">
			<el-button type="danger" @click.native="retrunbaseWork" v-if="!UnitInfo.isPublished">作业打回</el-button>
			<el-button type="warning" @click.native="Submitwork" v-if="!UnitInfo.isPublished">提交并发布分数</el-button>
		</el-col>		
		<el-col :span="24" style="text-align: center;" v-if="$route.query.stage==3">
			<el-button type="danger" @click.native="retrunWork" v-if="!UnitInfo.isInferPublished">沙盘复盘</el-button>
			<el-button type="warning" @click.native="SubmitTuistage" v-if="!UnitInfo.isInferPublished">提交并发布分数</el-button>
		</el-col>
		<el-col :span="24" style="text-align: center;" v-if="$route.query.stage==4">
			<el-button type="danger" @click.native="retrunWork" v-if="!UnitInfo.isRoadPublished">作业打回</el-button>
			<el-button type="warning" @click.native="SubmitTuistage" v-if="!UnitInfo.isRoadPublished">提交并发布分数</el-button>
		</el-col>		
	</section>
</template>

<script>
	import {coursunitget,coursgetstage,courseGetworkself,courseStudentSelf,courseTuiput,courseTeamedit,courseTeamSelf,courseTaskput,courseTeammark,courseTeamback,courseStucontent,courseStuedit,courseReturn} from '../../api/api'
	import dian from '../draw/dian.vue';
	import fenxi from '../draw/fenxi.vue';
	import lantu from '../draw/lantu.vue';
	import shangye from '../draw/shangye.vue';
	import yanjiang from '../draw/yanjiang.vue';
	import tiyan from '../draw/tiyan.vue';
	import { quillEditor } from 'vue-quill-editor' //调用编辑器
	 export default {
	 	data(){
	 		return{
	 			courseStages:[],
	 			UnitInfo:{},
	 			lookVisible:false,
	 			addFormVisible:false,
	 			path:"",
				Drawdian:{
					use:true,
					content:""
				},
				Drawfenxi:{
					use:true,
					content:""
				},
				Drawlantu:{
					use:true,
					content:""
				},
				Drawshangye:{
					use:true,
					content:""
				},
				Drawyanjiang:{
					use:true,
					content:""
				},
				Drawtiyan:{
					use:true,
					content:""
				},
				Drawnaotu:{
					use:true,
					content:""
				},			
	 			drawingTypeId:"",
	 			role:"",
	 			answerJson:[],
	 			stuquestion:[],
	 			Tuistage:{
	 				drawingJson:[],
	 				intro:"",
	 				isInferCommitted:1,
	 				inferVideoPath:""
	 			},
	 			Roadstage:{
	 				pdfFileList:[],
	 				videoFileList:[],
	 				intro:"",
	 				roadPdfPath:"",
	 				roadVideoPath:""
	 			},
	 			Roadparam:"",
	 			teamId:"",
	 			teamRole:"",
	 			TuifileList:[],
	 			Tuiparam:"",
	 			isInferCommitted:"",
	 			isRoadCommitted:"",
				user:{},
				addProScore:0,
				addScore:0,
	 		}
	 	},
	 	components:{'dians':dian,'fenxi':fenxi,'lantu':lantu,'shangye':shangye,'yanjiang':yanjiang,'tiyan':tiyan,quillEditor},
	 	methods:{
	 		ChangeaddScore:function(problemScore,score){
	 			if(problemScore>score){
					this.$message({
						message: '填写分数不能大于此题总分',
						type: 'error'
					});	 
					score=0;
					return score;		
	 			}
				var _this=this;
				_this.addScore=0;
				_this.addProScore=0;
	    		$.each(_this.UnitInfo.stageUnit.vproblems, function(e,value) {
	    			_this.addProScore+=parseInt(value.score);
	    			_this.addScore+=parseInt(value.problemScore);		
	    		});	
	    		_this.addScore=parseInt(_this.addScore/_this.addProScore*100);
	 		},
			returnScore: function () {
				var _this=this;
				var param=new URLSearchParams();
				param.append('courseId',this.$route.query.id);
				param.append('unitId',this.$route.query.unitId);
				param.append('userId',this.$route.query.userId);
				param.append('unitScore',this.addScore);
				courseStuedit(param).then((r) => {
				})
			},		 		
		    skip(link,id,unitId,stage,userId,user){
		        this.$router.push(
		        	{
		        		path:link,
		        		query:{
		        			id:id,
		        			unitId:unitId,
		        			stage:stage,
		        			userId:userId
		        		}
		        	}
		        )
		    },	
		    Roadskip(link,id,teamId,stage,row){
		        this.$router.push(
		        	{
		        		path:link,
		        		query:{
		        			id:id,
		        			teamId:teamId,
		        			stage:stage,
		        		}
		        	}
		        )
		    },	 		
			showdrawDislog:function(el){
				if(el.drawingTypeId=='1'){
					this.Drawtiyan.content=JSON.parse(el.content);
				}
				if(el.drawingTypeId=='2'){
					this.Drawdian.content=JSON.parse(el.content);
				}
				if(el.drawingTypeId=='3'){
					this.Drawlantu.content=JSON.parse(el.content);
				}
				if(el.drawingTypeId=='4'){
					this.Drawshangye.content=JSON.parse(el.content);
				}	
				if(el.drawingTypeId=='5'){
					this.Drawyanjiang.content=JSON.parse(el.content);
				}	
				if(el.drawingTypeId=='6'){
					this.Drawfenxi.content=JSON.parse(el.content);
				}		
				if(el.drawingTypeId=='7'){
					console.log(el)
					localStorage.setItem('use',0);							
					localStorage.setItem('Drawnaotu',el.content);		
				}		
				this.drawingTypeId=el.drawingTypeId;
				this.addFormVisible=true;
			},	
            beforeupload(file) {
                //创建临时的路径来展示图片
                var windowURL = window.URL || window.webkitURL;
                var videoname= file.name;     
                let onevideo={name:videoname,url:windowURL.createObjectURL(file)};
                this.TuifileList=[];
                this.TuifileList.push(onevideo);
                //重新写一个表单上传的方法
                this.Tuiparam = new FormData();
                this.Tuiparam.append('file', file, file.name);
                return false;
            },			
            roadpdfbeforeupload(file) {
                //创建临时的路径来展示图片
                var windowURL = window.URL || window.webkitURL;
                var videoname= file.name;     
                let onevideo={name:videoname,url:windowURL.createObjectURL(file)};
                this.Roadstage.pdfFileList=[];
                this.Roadstage.pdfFileList.push(onevideo);
                //重新写一个表单上传的方法
                this.Roadparam.append('pdfFile', file, file.name);
                return false;
            },
            roadvideobeforeupload(file) {
                //创建临时的路径来展示图片
                var windowURL = window.URL || window.webkitURL;
                var videoname= file.name;     
                let onevideo={name:videoname,url:windowURL.createObjectURL(file)};
                this.Roadstage.videoFileList=[];
                this.Roadstage.videoFileList.push(onevideo);
                //重新写一个表单上传的方法
                this.Roadparam.append('videoFile', file, file.name);
                return false;
            },            
			showDislog:function(el){
				if(el.drawingTypeId=='1'){
					this.Drawtiyan.content=el.content;
				}
				if(el.drawingTypeId=='2'){
					this.Drawdian.content=JSON.parse(el.content);
				}
				if(el.drawingTypeId=='3'){
					this.Drawlantu.content=JSON.parse(el.content);
				}
				if(el.drawingTypeId=='4'){
					this.Drawshangye.content=JSON.parse(el.content);
				}	
				if(el.drawingTypeId=='5'){
					this.Drawyanjiang.content=JSON.parse(el.content);
				}	
				if(el.drawingTypeId=='6'){
					this.Drawfenxi.content=JSON.parse(el.content);
				}		
				if(el.drawingTypeId=='7'){
					localStorage.setItem('Drawnaotu',el.content);		
				}		
				this.drawingTypeId=el.drawingTypeId;
				this.addFormVisible=true;
			},	 		
			lookvideo:function(path){
				this.path=path;
				this.lookVisible=true;
			},
			getTeam:function(teamId){	
				var _this=this;
				courseTeamSelf(_this.$route.query.teamId).then((res) =>{
					_this.UnitInfo=res
				});				
			},					
			//作业提交
			Submitwork: function () {
				var _this=this;	
				_this.answerJson=[];
				var pass=0;
				$.each(_this.UnitInfo.stageUnit.vproblems, function(i,res) {
					var oneswer={vproblemId:"",userId:"",courseId:"",answer:"",unitId:"",problemScore:"",remark:"",isMark:1}
					if(res.type==1){
						if(res.score<res.problemScore){
							pass=1;
						}
						oneswer.vproblemId=res.vproblemId;
						oneswer.userId=res.userId;
						oneswer.courseId=res.courseId;
						oneswer.problemScore=res.problemScore;
						oneswer.remark=res.remark;
						oneswer.unitId=res.unitId;
						oneswer.answer=res.answer;
						_this.answerJson.push(oneswer)					
					}

				});
				if(pass==1){
					this.$message({
						message: '填写分数不能大于设定分数',
						type: 'error'
					});			
					return;
				}
				var param=new URLSearchParams();
				param.append('markJson',JSON.stringify(_this.answerJson));
				this.$confirm('作业提交之后不能再次修改，确定提交作业吗？', '提示', {}).then(() => {
					courseTaskput(param).then((r) => {
						if(!r.error){
							this.returnScore();
							this.$message({
								message: '作业提交成功',
								type: 'success'
							});
							this.getstucourseInfo() 	
						}else{
							this.$message({
								message: '提交作业失败',
								type: 'error'
							});										
						}
					})
				});					
			},		
			//沙盘作业提交
			SubmitTuistage: function () {
				var _this=this;
				if(this.UnitInfo.inferScore<0 && this.$route.query.stage==3||this.UnitInfo.inferScore>100 ){
					_this.$message({
						message: '请输入0~100之内的分数',
						type: 'error'
					});		
					return
				};
				if(this.UnitInfo.roadScore<0 && this.$route.query.stage==4||this.UnitInfo.roadScore>100){
					_this.$message({
						message: '请输入0~100之内的分数',
						type: 'error'
					});		
					return
				};				
				var param=new URLSearchParams();
				param.append('teamId',_this.UnitInfo.teamId);
				if(this.$route.query.stage==3){
					param.append('inferScore',_this.UnitInfo.inferScore);
					param.append('inferRemark',_this.UnitInfo.inferRemark);		
				}
				if(this.$route.query.stage==4){
					param.append('roadScore',_this.UnitInfo.roadScore);
					param.append('roadRemark',_this.UnitInfo.roadRemark);
				}				
				this.$confirm('确定发布分数之后就不能修改，确定发布作业分数吗？', '提示', {}).then(() => {
					courseTeammark(param).then((r) => {
						if(!r.error){
							this.$message({
								message: '发布成功',
								type: 'success'
							});
							this.getTeam()						
						}else{
							this.$message({
								message: '发布失败',
								type: 'error'
							});										
						}
					})
				});					
			},	
			retrunbaseWork: function () {
				var _this=this;
				var param=new URLSearchParams();
				param.append('courseId',this.$route.query.id);
				param.append('unitId',this.$route.query.unitId);
				param.append('userId',this.$route.query.userId);
				param.append('isCommitted',false);
				this.$confirm('确定操作吗？', '提示', {}).then(() => {
					 courseReturn(param).then((r) => {
						if(!r.error){
							this.$message({
								message: '操作成功',
								type: 'success'
							});
							this.skip('/coursetaskstage',this.$route.query.id,this.$route.query.unitId,this.$route.query.stage)							
						}else{
							this.$message({
								message: '操作失败',
								type: 'error'
							});										
						}
					})
				});					
			},				
			//项目路演作业提交
			retrunWork: function () {
				var _this=this;
				var param=new URLSearchParams();
				param.append('teamId',this.$route.query.teamId);
				if(this.$route.query.stage==3){
					param.append('isInferCommitted',false);
							
				}
				if(this.$route.query.stage==4){
					param.append('isRoadCommitted',false);
				}
				this.$confirm('确定操作吗？', '提示', {}).then(() => {
					courseTeamback(param).then((r) => {
						if(!r.error){
							this.$message({
								message: '操作成功',
								type: 'success'
							});
							this.Roadskip('/coursetaskstage',this.$route.query.id,this.$route.query.unitId,this.$route.query.stage)						
						}else{
							this.$message({
								message: '操作失败',
								type: 'error'
							});										
						}
					})
				});					
			},				
			getStuWorkInfo:function(){
				var _this=this;
				var params={courseId:_this.$route.query.id,userId:_this.$store.state.userId,unitId:_this.$route.query.unitId};
				courseGetworkself(params).then((res)=>{
					_this.stuquestion=res
				})
			},
			getstucourseInfo:function(){
				var params =new URLSearchParams()
				params.append('courseId',this.$route.query.id)
				params.append('unitId',this.$route.query.unitId)
				params.append('userId',this.$route.query.userId)
				var _this=this;
				_this.addProScore=0;
				_this.addScore=0;
				courseStucontent(params).then((res)=>{	
		    		$.each(res.list[0].stageUnit.vproblems, function(e,value) {
		    			value.courseId=_this.$route.query.id;
		    			value.userId=_this.$route.query.userId;
		    			value.unitId=_this.$route.query.unitId;
		    			_this.addProScore+=parseInt(value.score);
	    				$.each(res.list[0].unitProblems, function(i,result) {
							if(value.type==3){
		    					if(value.vproblemId==result.vproblemId){
		    						value.answer=result.answer.split(',');
		    						value.problemScore=result.problemScore;
		    						value.remark=result.remark
		    					}									
							}else{
		    					if(value.vproblemId==result.vproblemId){
		    						value.answer=result.answer;
		    						value.problemScore=result.problemScore;
		    						value.remark=result.remark
		    					}									
							}						
	    				})		
		    		});	
    				$.each(res.list[0].unitProblems, function(i,result) {
    					_this.addScore+=result.problemScore;							
    				});		
    				if(res.list[0].isPublished){
    					_this.addScore=res.list[0].unitScore
    				}else{
    					_this.addScore=parseInt(_this.addScore/_this.addProScore*100);	
    				}							
		    		this.UnitInfo=res.list[0]
				})			
			},				
		    getUnitInfo:function(){
		    	var _this=this;
		    	_this.UnitInfo=JSON.parse(localStorage.getItem('taskuser'));

		    },
//		    getStageInfo:function(){
//		    	coursgetstage(this.$route.query.unitId).then((res)=>{
//		    		if(this.$route.query.stage==3){
//		    			res.name="沙盘推演"
//		    		}
//		    		if(this.$route.query.stage==4){
//		    			res.name="项目路演"
//		    		}		    		
//		    		this.UnitInfo=res
//		    	})
//		    }		    
	 	},
		mounted() {
			var _this=this
//			this.getstucourseInfo()
			this.$nextTick(function(){
				this.Roadparam=new FormData();
			    if(this.$route.query.stage==1||this.$route.query.stage==2){
					this.getstucourseInfo();		    	
			    }else{	    	
					_this.UnitInfo=JSON.parse(localStorage.getItem('taskuser'));				
			    }		
				setTimeout(function(){
					_this.role=_this.$store.state.role;
//					_this.getStuSelf()
				},500)			
			})

		}  	 	
	 }
</script>
<style scoped src='../../../static/css/style.css'>
</style>
<style>
	.courselink{
		cursor: pointer;
		font-size: 16px;
		display: block;
	}
	.courselink:hover{
		color:#20a0ff;
	}
	.video-box{
		padding: 0;
		position: relative;
		cursor: pointer;
	}
	.video-box .video-imgbox{
		width: 100%;
		height: 200px;
		overflow: hidden;
	}
	.video-box .iconfont{
		position: absolute;
		width: 100%;
		font-size: 50px;
		color:#fff;
		margin: 0;
		top: 0;
		line-height:200px;
		background:rgba(32,160,255,0.5)!important;
		text-align: center;
		transition: .5s all;
	}
	.video-box:hover .iconfont{
		color:#20a0ff;
		transition: .5s all;
	}
	.coursetags{
		cursor: pointer;
	}
</style>